<?php

namespace app\web\model;
use think\Db;
use think\Model;

class TestModel extends Model
{
    public function store()
    {
//        echo '门店页';die;
        $data = Db::table('shoporder') ->select();
//        var_dump($data);die;
        for($a=0; $a<count($data); $a++)
        {
            if(empty($data[$a]['pictrue'])){
                $data[$a]['icon'] = '/static/admin/img/default.jpg';
            }else{
                $data[$a]['icon'] = '/static/admin/img/'.$data[$a]['pictrue'];
            }
        }
//        var_dump($data);die;
        return $data;
    }

    public function search()
    {
        // var_dump($_POST);die;
        if (!empty($_POST['address'])) {
            $search = '%'.$_POST['address'].'%';
            $data = Db::table('shoporder') ->where('address','like',$search) ->select();
            // var_dump($data);die;
        }else{
            $data = Db::table('shoporder') ->select();
        }
        
        for($a=0; $a<count($data); $a++)
        {
            if(empty($data[$a]['pictrue'])){
                $data[$a]['icon'] = '/static/admin/img/default.jpg';
            }else{
                $data[$a]['icon'] = '/static/admin/img/'.$data[$a]['pictrue'];
            }
        }
            return $data;
//        var_dump($data);die;
    }

    public function menu()
    {
        $list = Db::table('category')->where('pid',0)->select();
        return $list;
    }

    public function account()
    {
        echo '个人中心页';die;
    }
}








